package com.gosophia.taskManagement.action;

import java.util.Collections;
import java.util.List;

import net.sf.json.JSONArray;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import com.gosophia.commons.web.action.BaseSupportAction;
import com.gosophia.dataDictionary.dto.DataValueDTO;
import com.gosophia.dataDictionary.ws.DataDictionaryWebService;
import com.gosophia.userManagement.dto.UserInfoDTO;
import com.gosophia.userManagement.ws.UserManagementWebService;

/**
 * 跳转到新建任务页面
 * @author mayue
 *
 */
@Controller("ToCreateMissionPageAction")
@Scope("prototype")
public class ToCreateMissionPageAction extends BaseSupportAction{

    private static final long serialVersionUID = 1L;
    
    @Autowired
    private DataDictionaryWebService dataDictionaryWebService;
    
    @Autowired
    private UserManagementWebService userManagementWebService;
    
    private List<DataValueDTO> importanceList ;
    
    private List<DataValueDTO> missionTypeList;
    
    private String undertakerListString;
    
    private static final Long IMPORTANCE_ENTRYID = 1014L;
    
    private static final Long MISSIONTYPE_ENTRYID =1015L;

    @Override
    public String _execute() throws Exception {
        //获取重要程度列表
        importanceList = dataDictionaryWebService.findEnabledDataValueByEntryId(IMPORTANCE_ENTRYID);
        Collections.reverse(importanceList);
        //任务类型列表
        missionTypeList = dataDictionaryWebService.findEnabledDataValueByEntryId(MISSIONTYPE_ENTRYID);
        //承办人列表json串
        List<UserInfoDTO> undertakerList = userManagementWebService.findAllUserInfoHasAccount();
        if(undertakerList!=null){
            undertakerListString = JSONArray.fromObject(undertakerList).toString().replace("\"", "\\\"");
        }
        return SUCCESS;
    }

    public List<DataValueDTO> getImportanceList() {
        return importanceList;
    }

    public void setImportanceList(List<DataValueDTO> importanceList) {
        this.importanceList = importanceList;
    }

    public List<DataValueDTO> getMissionTypeList() {
        return missionTypeList;
    }

    public void setMissionTypeList(List<DataValueDTO> missionTypeList) {
        this.missionTypeList = missionTypeList;
    }

    public String getUndertakerListString() {
        return undertakerListString;
    }

    public void setUndertakerListString(String undertakerListString) {
        this.undertakerListString = undertakerListString;
    }
    

}
